<?php
//error_reporting(E_ALL);
//date_default_timezone_set('Asia/Shanghai');
//require_once '../../lib/phpexcel/PHPExcel.php';
//require_once '../../lib/phpexcel/PHPExcel/Writer/Excel2007.php';

//require_once '../../lib/phpword/phpword.class.php';
//require_once '../../lib/phpword/PHPWord/IOFactory.php';

require_once '../../lib/vendor/autoload.php';

/**
 * The control file of company module of ZenTaoPMS.
 *
 * @copyright   Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      Chunsheng Wang <chunsheng@cnezsoft.com>
 * @package     company
 * @version     $Id: control.php 5100 2013-07-12 00:25:23Z zhujinyonging@gmail.com $
 * @link        http://www.zentao.net
 */
class approval extends control
{
    /**
     * Construct function, load dept and user models auto.
     *
     * @access public
     * @return void
     */
    public function __construct($moduleName = '', $methodName = '')
    {
        parent::__construct($moduleName, $methodName);
        $this->loadModel('dept');
    }

    /**
     * Index page, header to browse.
     *
     * @access public
     * @return void
     */
    public function index()
    {
        $this->locate($this->createLink('approval', 'browse'));
    }

    /**
     * 获取立项报告列表.
     *
     * @access public
     * @return void
     */
    public function browse() {
        $this->view->title = $this->lang->approval->browse;
        $this->view->position[] = $this->lang->approval->browse;

        $this->view->projects = array('' => '') + $this->loadModel('project')->getPairs();
        $this->view->users = array('' => '') + $this->loadModel('user')->getPairs('noletter|noclosed|nodeleted');
        $this->view->depts = $this->loadModel('dept')->getOptionMenu();

        $approvals = $this->dao->select('*')->from(TABLE_APPROVAL)
            ->fetchAll('id');

        $projects = $this->loadModel('project')->getPairs();
        $projectArray = array();
        foreach ($projects as $id => $project) {
            $projectArray[$project] = $id;
        }
        $companyApprovals = array();
        foreach ($approvals as $key => $approval) {
            $companyApprovals[$key]['code'] = $approval->code;
            $companyApprovals[$key]['project'] = $approval->project;
            $companyApprovals[$key]['projectId'] = $projectArray[$approval->project];
            $companyApprovals[$key]['leader'] = $approval->leader;
            $companyApprovals[$key]['apply'] = $approval->approvalDate;
            $companyApprovals[$key]['begin'] = $approval->beginDate;
            $companyApprovals[$key]['end'] = $approval->endDate;
            $companyApprovals[$key]['leaderGroup'] = $approval->dept;
            $companyApprovals[$key]['counterpart'] = $approval->counterpart;
            $companyApprovals[$key]['budget'] = $this->approval->covertUnit($approval->budget);
            $companyApprovals[$key]['number'] = $approval->number;
        }
        $this->session->approvalList = $companyApprovals;
        $this->view->approvals = $companyApprovals;
        $this->display();
    }

    /**
     * 根据编号查询立项报告.
     *
     * @param string $code 编号
     *
     * @access public
     * @return void
     */
    public function view($code = 0) {
        $this->view->title = $this->lang->approval->common;
        $this->view->position[] = $this->lang->approval->common;
        $this->view->projects = array('' => '') + $this->loadModel('project')->getPairs();
        $this->view->users = array('' => '') + $this->loadModel('user')->getPairs('noletter|noclosed|nodeleted');
        $this->view->depts = $this->loadModel('dept')->getOptionMenu();

        $approval = $this->approval->getApprovals($code);
        $this->view->approval = new stdclass();
        $itemValue = new stdclass();
        foreach ($approval as $item => $value) {
            $itemValue = $value;
            $this->view->approval->id                       = $value->id;
            $this->view->approval->code                     = $value->code;
            $this->view->approval->project                  = $value->project;
            $this->view->approval->leader                   = $value->leader;
            $this->view->approval->apply                    = $value->approvalDate;
            $this->view->approval->begin                    = $value->beginDate;
            $this->view->approval->end                      = $value->endDate;
            $this->view->approval->leaderGroup              = $value->dept;
            $this->view->approval->counterpart              = $value->counterpart;
            $this->view->approval->budget                   = $this->approval->covertUnit($value->budget);
            $this->view->approval->number                   = $value->number;
            $this->view->approval->rdCenter                 = ($value->rdCenter);
            $this->view->approval->technicalCommittee       = ($value->technicalCommittee);
            $this->view->approval->generalManager           = ($value->generalManager);
            $this->view->approval->remarks                  = ($value->remarks);

            $this->view->approval->marketDemand             = ($value->marketDemand);
            $this->view->approval->content                  = ($value->content);
            $this->view->approval->indicators               = ($value->indicators);
            $this->view->approval->difficulties             = ($value->difficulties);
            $this->view->approval->opponent                 = ($value->opponent);

            $this->view->approval->strategic                = ($value->strategic);
            $this->view->approval->feasibility              = $value->feasibility;
            $this->view->approval->market                   = ($value->market);
            $this->view->approval->strategy                 = ($value->strategy);
            $this->view->approval->productionConditions     = ($value->productionConditions);
            $this->view->approval->resourceAllocation       = ($value->resourceAllocation);
            $this->view->approval->competitiveAdvantage     = ($value->competitiveAdvantage);
        }
//        var_dump(strftime("%Y%m%d",strtotime(date('	2019-09-10'))) . time());
//        $project = $this->dao->select('*')->from(TABLE_PROJECT)->where('name')->eq($itemValue->project)->fetch();
//        var_dump($this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($project->id)->fetch());
        $this->display();
    }

    /**
     * 根据编号编辑立项报告.
     * @param string $code  编号
     * @access public
     * @return void
     */
    public function edit($code = '') {
        if (!empty($_POST)) {
            $this->approval->update();
            if (dao::isError()) die(js::error(dao::getError()));

            /* reset approval in session. */
            $approval = $this->approval->getApprovalByCode($code);
            $this->session->set('approval', $approval);

            die(js::reload('parent.parent'));
        }
        $this->view->title = $this->lang->approval->common;
        $this->view->position[] = $this->lang->approval->common;
        $this->view->projects = array('' => '') + $this->loadModel('project')->getPairs();
        $this->view->users = array('' => '') + $this->loadModel('user')->getByPairsQuery("role NOT IN('dev','po','')");//->getPairs('noletter|noclosed|nodeleted|pmfirst');
        $this->view->depts = $this->loadModel('dept')->getOptionMenu();

        if ($code) {
            $approval = $this->approval->getApprovals($code);
            $this->view->approval = new stdclass();
            foreach ($approval as $item => $value) {
                $this->view->approval->id                       = $value->id;
                $this->view->approval->code                     = $value->code;
                $this->view->approval->project                  = $value->project;
                $this->view->approval->leader                   = $value->leader;
                $this->view->approval->apply                    = $value->approvalDate;
                $this->view->approval->begin                    = $value->beginDate;
                $this->view->approval->end                      = $value->endDate;
                $this->view->approval->leaderGroup              = $value->dept;
                $this->view->approval->counterpart              = $value->counterpart;
                $this->view->approval->budget                   = ($value->budget);
                $this->view->approval->number                   = $value->number;
                $this->view->approval->remarks                  = $this->approval->cleanBr($value->remarks);

                $this->view->approval->marketDemand             = $this->approval->cleanBr($value->marketDemand);
                $this->view->approval->content                  = $this->approval->cleanBr($value->content);
                $this->view->approval->indicators               = $this->approval->cleanBr($value->indicators);
                $this->view->approval->difficulties             = $this->approval->cleanBr($value->difficulties);
                $this->view->approval->opponent                 = $this->approval->cleanBr($value->opponent);

                $this->view->approval->strategic                = $this->approval->cleanBr($value->strategic);
                $this->view->approval->feasibility              = $this->approval->cleanBr($value->feasibility);
                $this->view->approval->market                   = $this->approval->cleanBr($value->market);
                $this->view->approval->strategy                 = $this->approval->cleanBr($value->strategy);
                $this->view->approval->productionConditions     = $this->approval->cleanBr($value->productionConditions);
                $this->view->approval->resourceAllocation       = $this->approval->cleanBr($value->resourceAllocation);
                $this->view->approval->competitiveAdvantage     = $this->approval->cleanBr($value->competitiveAdvantage);
                $this->view->project = $this->dao->select('*')->from(TABLE_PROJECT)->where('name')->eq($value->project)->fetch();
            }
        }
        $this->display();
    }

    /**
     * 根据编号删除立项报告（逻辑删除）.
     *
     * @param string $code  编号
     *
     * @access public
     * @return void
     */
    public function delete($code = '') {
        $approval = $this->approval->getApprovalByCode($code);
        if (empty($approval)) return;
        if (!empty($_POST)) {
            if(md5($this->post->verifyPassword) != $this->app->user->password) {
                die(js::alert($this->lang->user->error->verifyPassword));
            }
            $this->approval->delete($code);
            if (dao::isError()) die(js::error(dao::getError()));

            die(js::reload('parent.parent'));
        }

        $this->view->title      = $this->lang->approval->delete . $this->lang->approval->common;
        $this->view->position[] = $this->lang->approval->delete . $this->lang->approval->common;
        $this->view->code       = $code;
        $this->display();
    }

    /**
     * 根据编号导出立项报告（Word）
     *
     * @param string $code  编号
     *
     * @access public
     * @return void
     */
    public function export($code = '') {
        if (empty($code)) return;

        $approvals = $this->approval->getApprovals($code);


        $styleCell = array('valign'=>'center');
        $fontStyle = array('bold'=>true, 'align'=>'center');

        // Define table style arrays
        $styleTable = array('borderSize'=>6, 'borderColor'=>'006699', 'cellMargin'=>80);
        $styleFirstRow = array('borderBottomSize'=>18, 'borderBottomColor'=>'0000FF', 'bgColor'=>'66BBFF');
        $approval = new stdclass();
        foreach ($approvals as $item => $value) {
            $approval = $value;
        }
        $approval = $this->approval->getApprovalByCode($code);

        $this->writeApprovalToWord($approval);
//        writeExcel($approval);

    }

    /**
     * 输出Word文件
     *
     * @param array $approval  立项报告
     *
     * @access private
     * @return void
     */
    private function writeApprovalToWord($approval) {
//        $projects = array('' => '') + $this->loadModel('project')->getPairs();
        $users = array('' => '') + $this->loadModel('user')->getPairs('noletter|noclosed|nodeleted');
        $depts = $this->loadModel('dept')->getOptionMenu();
        $title = $approval->project . '研发' . $this->lang->approval->common;

        $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('Template.docx');
        $templateProcessor->setValue('project', $approval->project);
        $templateProcessor->setValue('leader', $users[$approval->leader]);
        $templateProcessor->setValue('approvalDate', $approval->approvalDate);
        $templateProcessor->setValue('beginDate', $approval->beginDate);
        $templateProcessor->setValue('endDate', $approval->endDate);
        $deptName = $depts[$approval->dept];
        $templateProcessor->setValue('dept', mb_substr($deptName,1,mb_strlen($deptName),'utf-8'));
        $templateProcessor->setValue('counterpart', $approval->counterpart);
        $templateProcessor->setValue('budget', $this->approval->covertUnit($approval->budget));
        $templateProcessor->setValue('number', $approval->number);

        $templateProcessor->setValue('marketDemand', $this->approval->brCoverEnter($approval->marketDemand));
        $templateProcessor->setValue('content', $this->approval->brCoverEnter($approval->content));
        $templateProcessor->setValue('indicators', $this->approval->brCoverEnter($approval->indicators));
        $templateProcessor->setValue('difficulties', $this->approval->brCoverEnter($approval->difficulties));
        $templateProcessor->setValue('opponent',  $this->approval->brCoverEnter($approval->opponent));

        $templateProcessor->setValue('strategic', $this->approval->brCoverEnter($approval->strategic));
        $templateProcessor->setValue('feasibility', $this->approval->brCoverEnter($approval->feasibility));
        $templateProcessor->setValue('market', $this->approval->brCoverEnter($approval->market));
        $templateProcessor->setValue('strategy', $this->approval->brCoverEnter($approval->strategy));
        $templateProcessor->setValue('productionConditions',  $this->approval->brCoverEnter($approval->productionConditions));
        $templateProcessor->setValue('resourceAllocation',  $this->approval->brCoverEnter($approval->resourceAllocation));
        $templateProcessor->setValue('competitiveAdvantage',  $this->approval->brCoverEnter($approval->competitiveAdvantage));

        $filename = urlencode($title).'_'.date('Y-m-d-His');
        header("Content-Disposition: attachment; filename='. $filename .docx'");
        $templateProcessor->saveAs('php://output');

//        $PHPWord = new PhpOffice\PhpWord\PhpWord();
//        $PHPWord->setDefaultFontName('仿宋'); // 全局字体
//        $PHPWord->setDefaultFontSize(12);   // 全局字号为3号
////        设置标题
//        $PHPWord->addFontStyle('rStyle', array('bold'=>true, 'italic'=>true, 'size'=>16));
//        $PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter'=>100));
//        $section = $PHPWord->createSection();
//
//        $PHPWord->addTitleStyle(2,array("bold"=>true, 'size'=>18),array('align'=>'center', 'spaceAfter'=>100));
//        $section->addTitle(($approval->project . $this->lang->approval->common),2);
//
//        $section->addTextBreak(3);
//
//        $captionTable = array('borderSize'=>1, 'borderColor'=>'000000', 'cellMargin'=>100 , 'bgColor'=>'D5D5D5'); //表格样式
//        $thTable = array('borderSize'=>1, 'borderColor'=>'000000', 'cellMargin'=>100,'valign'=>'center'); //表格样式
//        $thSytle = array('size'=>12, 'bold'=>true); //文字样式
//        $tdTable = array('borderSize'=>1, 'borderColor'=>'000000', 'cellMargin'=>100,'valign'=>'center','align'=>'left'); //表格样式
//
//        $tableStyle = array(
//            'borderSize'  => 1,
//            'borderColor'=>'333333',
//            'cellMargin'  => 50,
//            'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::START
//        );
//
//        $baseTable = $section->addTable($tableStyle);
//
//        $baseTable->addRow(400);
//        $captionCell = $baseTable->addCell(9500);
//        $captionCell->getStyle()->setGridSpan(4)->setArrayStyle($captionTable);
//        $captionCell->addText("基本信息",array('size'=>14, 'bold'=>true));
//
//        $baseTable->addRow(400);
//        $projectCell = $baseTable->addCell(2000,$thTable);
//        $projectCell->addText(($this->lang->approval->project),$thSytle);
//        $projectCellValue = $baseTable->addCell(7500);
//        $projectCellValue->getStyle()->setGridSpan(3)->setArrayStyle($tdTable);
//        $projectCellValue->addText($approval->project);
//
//        $baseTable->addRow(400);
//        $baseTable->addCell(2000,$thTable)->addText($this->lang->approval->leader,$thSytle);
//        $baseTable->addCell(2500,$tdTable)->addText($users[$approval->leader]);
//        $baseTable->addCell(2500,$thTable)->addText($this->lang->approval->apply,$thSytle);
//        $baseTable->addCell(2500,$tdTable)->addText($approval->approvalDate);
//
//        $baseTable->addRow(400);
//        $baseTable->addCell(2000,$thTable)->addText($this->lang->approval->begin,$thSytle);
//        $baseTable->addCell(2500,$tdTable)->addText($approval->beginDate);
//        $baseTable->addCell(2500,$thTable)->addText($this->lang->approval->end,$thSytle);
//        $baseTable->addCell(2500,$tdTable)->addText($approval->endDate);
//
//        $baseTable->addRow(400);
//        $baseTable->addCell(2000,$thTable)->addText($this->lang->approval->leaderGroup,$thSytle);
//        $deptName = $depts[$approval->dept];
//        $baseTable->addCell(2500,$tdTable)->addText(mb_substr($deptName,1,mb_strlen($deptName),'utf-8'));
//        $baseTable->addCell(2500,$thTable)->addText($this->lang->approval->counterpart,$thSytle);
//        $baseTable->addCell(2500,$tdTable)->addText($approval->counterpart);
//
//        $baseTable->addRow(400);
//        $baseTable->addCell(2000,$thTable)->addText($this->lang->approval->budget,$thSytle);
//        $baseTable->addCell(2500,$tdTable)->addText($this->covertUnit($approval->budget));
//        $baseTable->addCell(2500,$thTable)->addText($this->lang->approval->number,$thSytle);
//        $baseTable->addCell(2500,$tdTable)->addText($approval->number . ' 人');
//
//        $baseTable->addRow(1400);
//        $baseTable->addCell(2000,$thTable)->addText($this->lang->approval->rdCenter .'(姓名/日期)',$thSytle);
//        $rdCenterCell = $baseTable->addCell(7500,$tdTable);
//        $rdCenterCell->getStyle()->setGridSpan(3);
//        $rdCenterCell->addText($approval->rdCenter);
//
//        $baseTable->addRow(1400);
//        $baseTable->addCell(2000,$thTable)->addText($this->lang->approval->technicalCommittee . '(姓名/日期)',$thSytle);
//        $technicalCommitteeCell = $baseTable->addCell(7500,$tdTable);
//        $technicalCommitteeCell->getStyle()->setGridSpan(3);
//        $technicalCommitteeCell->addText($approval->technicalCommittee);
//
//        $baseTable->addRow(1400);
//        $baseTable->addCell(2000,$thTable)->addText($this->lang->approval->generalManager . '(姓名/日期)',$thSytle);
//        $generalManagerCell = $baseTable->addCell(7500,$tdTable);
//        $generalManagerCell->getStyle()->setGridSpan(3);
//        $generalManagerCell->addText($approval->generalManager);
//
//        $baseTable->addRow(1400);
//        $baseTable->addCell(2000,$thTable)->addText($this->lang->approval->financial . '(姓名/日期)',$thSytle);
//        $financialCell = $baseTable->addCell(7500,$tdTable);
//        $financialCell->getStyle()->setGridSpan(3);
//        $financialCell->addText($approval->financial);
//
//        $baseTable->addRow(1400);
//        $baseTable->addCell(2000,$thTable)->addText($this->lang->approval->remarks,$thSytle);
//        $remarksCell = $baseTable->addCell(7500,$tdTable);
//        $remarksCell->getStyle()->setGridSpan(3);
//        $remarksCell->addText($approval->remarks);
//
//        $section->addTextBreak(5);
//        $section->addPageBreak();
//
//        $bgTable = $section->addTable($tableStyle);
//        $bgTable->addRow(400);
//        $bgCaptionCell = $bgTable->addCell(9500);
//        $bgCaptionCell->getStyle()->setGridSpan(4)->setArrayStyle($captionTable);
//        $bgCaptionCell->addText("项目背景及研发内容",array('size'=>14, 'bold'=>true));
//
//        $bgTable->addRow(400);
//        $bgTable->addCell(2000,$thTable)->addText(($this->lang->approval->project),$thSytle);
//        $bgProjectCell = $bgTable->addCell(7500,$tdTable);
//        $bgProjectCell->getStyle()->setGridSpan(3);
//        $bgProjectCell->addText($approval->project);
//
//        $bgTable->addRow(1400);
//        $bgTable->addCell(2000,$thTable)->addText($this->lang->approval->marketDemand,$thSytle);
//        $marketDemandCell = $bgTable->addCell(7500,$tdTable);
//        $marketDemandCell->getStyle()->setGridSpan(3);
//        $marketDemandCell->addText($this->approval->brCoverEnter($approval->marketDemand));
//
//        $bgTable->addRow(1400);
//        $bgTable->addCell(2000,$thTable)->addText($this->lang->approval->content,$thSytle);
//        $contentCell = $bgTable->addCell(7500,$tdTable);
//        $contentCell->getStyle()->setGridSpan(3);
//        $contentCell->addText($this->approval->brCoverEnter($approval->content));
//
//        $bgTable->addRow(1400);
//        $bgTable->addCell(2000,$thTable)->addText($this->lang->approval->indicators,$thSytle);
//        $indicatorsCell = $bgTable->addCell(7500,$tdTable);
//        $indicatorsCell->getStyle()->setGridSpan(3);
//        $indicatorsCell->addText($this->approval->brCoverEnter($approval->indicators));
//
//        $bgTable->addRow(1400);
//        $bgTable->addCell(2000,$thTable)->addText($this->lang->approval->difficulties,$thSytle);
//        $difficultiesCell = $bgTable->addCell(7500,$tdTable);
//        $difficultiesCell->getStyle()->setGridSpan(3);
//        $difficultiesCell->addText($this->approval->brCoverEnter($approval->difficulties));
//
//        $bgTable->addRow(1400);
//        $bgTable->addCell(2000,$thTable)->addText($this->lang->approval->opponent,$thSytle);
//        $opponentCell = $bgTable->addCell(7500,$tdTable);
//        $opponentCell->getStyle()->setGridSpan(3);
//        $opponentCell->addText($this->approval->brCoverEnter($approval->opponent));

//        $section->addPageBreak();
//
//        $psTable = $section->addTable($tableStyle);
//        $psTable->addRow(400);
//        $psCaptionCell = $bgTable->addCell(9500);
//        $psCaptionCell->getStyle()->setGridSpan(4)->setArrayStyle($captionTable);
//        $psCaptionCell->addText("评审依据",array('size'=>14, 'bold'=>true));
//
//        $psTable->addRow(400);
//        $psTable->addCell(2000,$thTable)->addText(($this->lang->approval->project),$thSytle);
//        $psProjectCell = $bgTable->addCell(7500,$tdTable);
//        $psProjectCell->getStyle()->setGridSpan(3);
//        $psProjectCell->addText($approval->project);
//
//        $psTable->addRow(1400);
//        $psTable->addCell(2000,$thTable)->addText($this->lang->approval->strategic,$thSytle);
//        $strategicCell = $bgTable->addCell(7500,$tdTable);
//        $strategicCell->getStyle()->setGridSpan(3);
//        $strategicCell->addText($this->approval->brCoverEnter($approval->strategic));
//
//        $bgTable->addRow(1400);
//        $bgTable->addCell(2000,$thTable)->addText($this->lang->approval->feasibility,$thSytle);
//        $feasibilityCell = $bgTable->addCell(7500,$tdTable);
//        $feasibilityCell->getStyle()->setGridSpan(3);
//        $feasibilityCell->addText($this->approval->brCoverEnter($approval->feasibility));
//
//        $psTable->addRow(1400);
//        $psTable->addCell(2000,$thTable)->addText($this->lang->approval->market,$thSytle);
//        $marketCell = $bgTable->addCell(7500,$tdTable);
//        $marketCell->getStyle()->setGridSpan(3);
//        $marketCell->addText($this->approval->brCoverEnter($approval->market));
//
//        $psTable->addRow(1400);
//        $psTable->addCell(2000,$thTable)->addText($this->lang->approval->strategy,$thSytle);
//        $strategyCell = $bgTable->addCell(7500,$tdTable);
//        $strategyCell->getStyle()->setGridSpan(3);
//        $strategyCell->addText($this->approval->brCoverEnter($approval->strategy));
//
//        $psTable->addRow(1400);
//        $psTable->addCell(2000,$thTable)->addText($this->lang->approval->productionConditions,$thSytle);
//        $productionConditionsCell = $bgTable->addCell(7500,$tdTable);
//        $productionConditionsCell->getStyle()->setGridSpan(3);
//        $productionConditionsCell->addText($this->approval->brCoverEnter($approval->productionConditions));
//
//        $psTable->addRow(1400);
//        $psTable->addCell(2000,$thTable)->addText($this->lang->approval->resourceAllocation,$thSytle);
//        $resourceAllocationCell = $bgTable->addCell(7500,$tdTable);
//        $resourceAllocationCell->getStyle()->setGridSpan(3);
//        $resourceAllocationCell->addText($this->approval->brCoverEnter($approval->resourceAllocation));
//
//        $psTable->addRow(1400);
//        $psTable->addCell(2000,$thTable)->addText($this->lang->approval->competitiveAdvantage,$thSytle);
//        $competitiveAdvantageCell = $bgTable->addCell(7500,$tdTable);
//        $competitiveAdvantageCell->getStyle()->setGridSpan(3);
//        $competitiveAdvantageCell->addText($this->approval->brCoverEnter($approval->competitiveAdvantage));
//
//        $footer = $section->createFooter();
//        $footer->addPreserveText('第{PAGE}页 共{NUMPAGES}页',array('size'=> 10,'color'=>'999999'),array('align'=>'center'));
//        $header = $section->createHeader();
//        $header->addText('亚康科技 - 研发立项报告                                   内部资料,注意保密',array('size'=> 10,'color'=>'999999'),array('align'=>'justify '));
//
//        $filename = urlencode($title).'_'.date('Y-m-dHis');
//        header("Content-Type:application/vnd.openxmlformats-officedocument.wordprocessingml.document");
//        header('Content-Disposition: attachment;filename="'.$filename.'.docx"');
//        header('Cache-Control: max-age=0');
//        header("Pragma:no-cache");
//        header("Expires:0");
//        $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007');
//        $objWriter->save('php://output');

        exit;
    }

}
